package cn.ly.jvm.loader.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCCharset {
	
	public static void main(String[] args) {
		try{
			Class.forName("com.mysql.jdbc.Driver");
			String mysqlUrl = "jdbc:mysql://192.168.0.121:3306/testdb?useUnicode=true&characterEncoding=latin1&autoReconnect=true&allowMultiQueries=true";	 
			Connection conn = null;
			Statement st = null;
			ResultSet rs = null;
			try {
				conn = DriverManager.getConnection(mysqlUrl, "root", "root"); 
				st = conn.createStatement();
				rs = st.executeQuery("select id,name from USER where id=1");
				while(rs.next()){
					System.out.println(rs.getInt("id") + "," + rs.getString("name"));
				}
			} finally {
				if(rs != null) rs.close();
				if(st != null) st.close();
				if(conn != null) conn.close();
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
